package com.example.basemvvmkotlin.net

import com.example.lib_base.base.http.BaseHttpClient
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import retrofit2.Retrofit

class MyApiClient: BaseHttpClient() {

    companion object {
        @Volatile
        private var instance: MyApiClient? = null

        @JvmStatic
        fun getInstance() =
            instance ?: synchronized(this) {
                instance ?: MyApiClient().also { instance = it }
            }
    }

    var build = "1"

    override fun getBaseUrl(): String {
      return "https://app.syiptv.com/"
    }

    override fun isDebug(): Boolean {
       return false
    }

    override fun handleOkBuilder(builder: OkHttpClient.Builder) {
        builder.addInterceptor(object : Interceptor {
            override fun intercept(chain: Interceptor.Chain): Response {
                var request = chain.request()
                    .newBuilder()
                    .addHeader("sygd-platform","ios")
                    .addHeader("sygd-build",build)
                    .build()
                return chain.proceed(request);
            }
        })
    }

    override fun handleRetrofitBuilder(builder: Retrofit.Builder) {

    }
}